import 'package:lcapp/data/xian_huo_data_entity.dart';
import 'package:lcapp/data/media_asset_data_entity.dart';

xianHuoDataEntityFromJson(XianHuoDataEntity data, Map<String, dynamic> json) {
	if (json['id'] != null) {
		data.id = json['id'] is String
				? int.tryParse(json['id'])
				: json['id'].toInt();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['price'] != null) {
		data.price = json['price'].toString();
	}
	if (json['production'] != null) {
		data.production = json['production'].toString();
	}
	if (json['images'] != null) {
		data.images = (json['images'] as List).map((v) => v.toString()).toList().cast<String>();
	}
	if (json['year'] != null) {
		data.year = json['year'].toString();
	}
	if (json['numbers'] != null) {
		data.numbers = json['numbers'].toString();
	}
	if (json['publishType'] != null) {
		data.publishType = json['publishType'] is String
				? int.tryParse(json['publishType'])
				: json['publishType'].toInt();
	}
	if (json['bargain'] != null) {
		data.bargain = json['bargain'] is String
				? int.tryParse(json['bargain'])
				: json['bargain'].toInt();
	}
	if (json['status'] != null) {
		data.status = json['status'] is String
				? int.tryParse(json['status'])
				: json['status'].toInt();
	}
	if (json['store'] != null) {
		data.store = json['store'].toString();
	}
	if (json['address'] != null) {
		data.address = json['address'].toString();
	}
	if (json['longitude'] != null) {
		data.longitude = json['longitude'].toString();
	}
	if (json['latitude'] != null) {
		data.latitude = json['latitude'].toString();
	}
	if (json['description'] != null) {
		data.description = json['description'].toString();
	}
	if (json['user'] != null) {
		data.user = XianHuoUserEntity().fromJson(json['user']);
	}
	if (json['type'] != null) {
		data.type = json['type'] is String
				? int.tryParse(json['type'])
				: json['type'].toInt();
	}
	if (json['typeName'] != null) {
		data.typeName = json['typeName'].toString();
	}
	if (json['updateTime'] != null) {
		data.updateTime = json['updateTime'].toString();
	}
	if (json['productUnit'] != null) {
		data.productUnit = json['productUnit'] is String
				? int.tryParse(json['productUnit'])
				: json['productUnit'].toInt();
	}
	if (json['distance'] != null) {
		data.distance = json['distance'].toString();
	}
	if (json['isChoose'] != null) {
		data.isChoose = json['isChoose'];
	}
	return data;
}

Map<String, dynamic> xianHuoDataEntityToJson(XianHuoDataEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['id'] = entity.id;
	data['name'] = entity.name;
	data['price'] = entity.price;
	data['production'] = entity.production;
	data['images'] = entity.images;
	data['year'] = entity.year;
	data['numbers'] = entity.numbers;
	data['publishType'] = entity.publishType;
	data['bargain'] = entity.bargain;
	data['status'] = entity.status;
	data['store'] = entity.store;
	data['address'] = entity.address;
	data['longitude'] = entity.longitude;
	data['latitude'] = entity.latitude;
	data['description'] = entity.description;
	data['user'] = entity.user?.toJson();
	data['type'] = entity.type;
	data['typeName'] = entity.typeName;
	data['updateTime'] = entity.updateTime;
	data['productUnit'] = entity.productUnit;
	data['distance'] = entity.distance;
	data['isChoose'] = entity.isChoose;
	return data;
}

xianHuoUserEntityFromJson(XianHuoUserEntity data, Map<String, dynamic> json) {
	if (json['userId'] != null) {
		data.userId = json['userId'] is String
				? int.tryParse(json['userId'])
				: json['userId'].toInt();
	}
	if (json['img'] != null) {
		data.img = json['img'].toString();
	}
	if (json['name'] != null) {
		data.name = json['name'].toString();
	}
	if (json['realName'] != null) {
		data.realName = json['realName'].toString();
	}
	if (json['vip'] != null) {
		data.vip = json['vip'] is String
				? int.tryParse(json['vip'])
				: json['vip'].toInt();
	}
	if (json['card'] != null) {
		data.card = json['card'] is String
				? int.tryParse(json['card'])
				: json['card'].toInt();
	}
	if (json['number'] != null) {
		data.number = json['number'] is String
				? int.tryParse(json['number'])
				: json['number'].toInt();
	}
	if (json['phone'] != null) {
		data.phone = json['phone'].toString();
	}
	if (json['attentionState'] != null) {
		data.attentionState = json['attentionState'] is String
				? int.tryParse(json['attentionState'])
				: json['attentionState'].toInt();
	}
	return data;
}

Map<String, dynamic> xianHuoUserEntityToJson(XianHuoUserEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['userId'] = entity.userId;
	data['img'] = entity.img;
	data['name'] = entity.name;
	data['realName'] = entity.realName;
	data['vip'] = entity.vip;
	data['card'] = entity.card;
	data['number'] = entity.number;
	data['phone'] = entity.phone;
	data['attentionState'] = entity.attentionState;
	return data;
}